<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>商之联后台管理系统</title>
  <meta name="description" content="这是一个 table 页面">
  <meta name="keywords" content="table">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="icon" type="image/png" href="{:C('ADMIN_IMAGE')}favicon.png"> <link rel="apple-touch-icon-precomposed" href="{:C('ADMIN_IMAGE')}app-icon72x72@2x.png">
  <meta name="apple-mobile-web-app-title" content="Amaze UI" />
  <link rel="stylesheet" href="{:C('ADMIN_CSS')}amazeui.min.css"/>
  <link rel="stylesheet" href="{:C('ADMIN_CSS')}admin.css">
</head>
<body>
<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
  以获得更好的体验！</p>
<![endif]-->

<!-- header start-->

<include file="Public:header"/>

<!-- header end-->

<div class="am-cf admin-main">
<!-- sidebar start -->
   <include file="Public:menu"/>
  <!-- sidebar end -->
  
  <!-- content start -->
  <div class="admin-content">

    <div class="am-cf am-padding">
      <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">活动设备管理</strong> / <small>设备列表</small></div>
    </div>
    <div class="am-g activ_item_search">
      <div class="selptheme" > 
      活动主题:<select name="ptheme" >
        <option value="0" >请选择</option>
        <foreach name="theme" item="the" key='key'>
        <option value="{$key}">{$the}</option>
        </foreach>
        </select>
      </div>
     
     
    <!--筛选 start-->
    <div class='am-g'>
    <div class="am-u-sm-12 activ_tool">
      <button type="button" class="am-btn am-btn-primary am-btn-xs seachactiv">搜索</button>
   
    </div>
    </div>
    <!--筛选end-->
    <div class="am-g">
      <div class="am-u-sm-12">
       
          <table class="am-table am-table-striped am-table-hover table-main  devicetalbe" >
            <thead>
              <tr>
                <th class="table-title">活动主题</th>
                <th class="table-title">参与设备</th>
                <th class="table-title">操作</th>   
              </tr>
          </thead>
          <tbody>
            <foreach name="devices" item='device'>
            <tr>
              <td>{$device['activityid']}</td>
              <td>{$device['devicecode']}</td>
              <td>        
                  <div class="am-btn-group am-btn-group-xs">             
                    <span class="am-icon-trash"><a  href="javascript:void(0)"  value='{$device['id']}' class="delPro">删除</a></span>                    
                  </div>
              </td>
            </tr>
            </foreach>
          </tbody>
        </table>
        
        <!-- 分页start-->
           <div class="am-fr devicepage">
          <ul class="am-pagination" >
            <li>共<label class="count"> {$pagearr['count']}</label> 条记录</li>
            <li>共<label class="pagetotal" > {$pagearr['pagetotal']}</label> 页</li>          
            <li>当前第 <label class="currentpage"> {$pagearr['page']} </label> 页</li>
            <li><a href="javascript:pageajax('firpage')" class="firpage" value="1" >第一页</a></li>
            <li><a href="javascript:pageajax('prepage')" class="prepage" value={$pagearr['page']-1}>上一页</a></li>
            <li><a href="javascript:pageajax('nexpage')" class="nexpage" value={$pagearr['page']+1}>下一页</a></li>
            <li><a href="javascript:pageajax('pagetotal')" class="laspage" value={$pagearr['pagetotal']}>最末页</a></li>
          </ul>
  </div>
        <!-- 分页end-->

        
      </div>

    </div>
  </div>
  <!-- content end -->
</div>



<script src="{:C('ADMIN_JS')}jquery.min.js"></script>
<include file="Public:footer"/>

<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="{:C('ADMIN_JS')}polyfill/rem.min.js"></script>
<script src="{:C('ADMIN_JS')}polyfill/respond.min.js"></script>
<script src="{:C('ADMIN_JS')}amazeui.legacy.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="{:C('ADMIN_JS')}amazeui.min.js"></script>
<!--<![endif]-->
<script src="{:C('ADMIN_JS')}app.js"></script>
<!-- <script src="{:C('ADMIN_JS')}admin.js"></script> -->
<script type="text/javascript">
 var Sear=function(page){
  ///$(".seachactiv").click(function(){
   var $activityid=$("select[name='ptheme'] option:selected").val();
    var page = arguments[0]?arguments[0] : 1;

     $.ajax({
      type:'POST',
        url:"{:U('Activity/Seardevice')}",
        data:{"activityid":$activityid,"page":page},
        dataType:"json",
         success:function(message){
           var $page=message.pagearr; //底部分页
           var $devices=message.devices;//设备
           var $tbody=$('<tbody></tbody>');
           var $string='';
          if(message.status)
          {
           $.each($devices,function(key,devices)
           {
             $string+='<tr>' ;
             $string+='<td>'+devices.activityid+'</td>';
             $string+='<td>'+devices.devicecode+'</td>';
             $string+='<td><div class="am-btn-group am-btn-group-xs"><span class="am-icon-trash"><a  href="javascript:void(0)" class="delPro" value='+devices.id+'>删除</a></td>';
             
           });/////遍历数据结束
               $tbody.append($string);
              $($tbody).replaceAll("tbody");
              $(".count").html($page.count);
              $(".pagetotal").html($page.pagetotal);
              $(".currentpage").html($page.page);
              $('.prepage').attr('value',$page.prevpage);
              $('.nexpage').attr('value', $page.nextpage);
              $('.laspage').attr('value',$page.pagetotal);
          }/////存在数据end
          else{
            $('.devicetalbe tbody').html('暂无数据');
             $('.devicepage').hide();
          }
         }

       })




}


////翻页事件
 //翻页事件
  function pageajax(name){
     var pagevalue=$('.'+name).attr('value');
     Sear(pagevalue);
     return false;
  }
  ////
  $(".seachactiv").click(function(){
    Sear();
  })
</script>
<script type="text/javascript">
  ////删除设备
  $(document).on('click','.delPro',function(){
  var res=confirm("确定要删除该活动");
  if(!res){
    return false;
  }
  var $this=$(this);
  var id=$this.attr('value');
   jQuery.get('{:U("Activity/deldevice")}',
  {id:id,},
  function(data)
  {
     if(data.status==200)
     {
       alert(data.info);
     }
  },'json')
 })
</script>

</body>
</html>
